/*
 * @Author: benchenchuang benchenchuang
 * @Date: 2023-08-06 18:38:52
 * @LastEditors: benchenchuang benchenchuang
 * @LastEditTime: 2023-08-06 18:45:49
 * @FilePath: /vite-vue-ts/vite.config.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite';
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [
        vue(),
        AutoImport({
            imports: ["vue",'vue-router'],
            dts: "src/auto-import.d.ts",
            resolvers: [AntDesignVueResolver()],
        }),
        Components({
            resolvers: [
                AntDesignVueResolver({
                    importStyle: false
                }),
            ],
        }),
        createSvgIconsPlugin({
            // 要缓存的图标文件夹
            iconDirs: [path.resolve(__dirname, 'src/icons')],
            // 执行 icon name 的格式
            symbolId: 'icon-[name]'
        })
    ],
    server: {
        port: 3030,
        host: '0.0.0.0',
        open: true,
        proxy: {
            '/api': {
                target: "http://127.0.0.1:8086",
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, ""),
            }
        }
    },
    resolve: {
        alias: {
            '@': path.resolve(__dirname, 'src')
        }
    },
    css: {
        preprocessorOptions: {
            scss: {
                additionalData: `@use '@/styles/var.scss' as *;`
            }
        }
    }
})

